﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace StudioEditorTest.CodeEditor
{
	public interface IExtendedListViewContentItem
	{
		//bool IsSelected { get; }
		//Rect SelectedRegion { get; set; }
		Rect Bounds { get; set; }
		int Index { get; set; }
	}

	public class ExtendedListViewContentItem : DependencyObject, IExtendedListViewContentItem
	{
		// Using a DependencyProperty as the backing store for IsSelected.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty IsSelectedProperty =
			DependencyProperty.Register("IsSelected", typeof(bool), typeof(ExtendedListViewContentItem), new UIPropertyMetadata(false));

		// Using a DependencyProperty as the backing store for SelectedRegion.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty SelectedRegionProperty =
			DependencyProperty.Register("SelectedRegion", typeof(Rect), typeof(ExtendedListViewContentItem), new UIPropertyMetadata(Rect.Empty, SelectedRegionChangedCallback));

		// Using a DependencyProperty as the backing store for Bounds.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty BoundsProperty =
			DependencyProperty.Register("Bounds", typeof(Rect), typeof(ExtendedListViewContentItem), new UIPropertyMetadata(Rect.Empty));

		// Using a DependencyProperty as the backing store for Index.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty IndexProperty =
			DependencyProperty.Register("Index", typeof(int), typeof(ExtendedListViewContentItem), new UIPropertyMetadata(-1));

		private static void SelectedRegionChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			d.SetValue(IsSelectedProperty, ((Rect)e.NewValue) != Rect.Empty);
		}

		public bool IsSelected
		{
			get { return (bool)GetValue(IsSelectedProperty); }
		}

		public Rect SelectedRegion
		{
			get { return (Rect)GetValue(SelectedRegionProperty); }
			set { SetValue(SelectedRegionProperty, value); }
		}

		public Rect Bounds
		{
			get { return (Rect)GetValue(BoundsProperty); }
			set { SetValue(BoundsProperty, value); }
		}

		public int Index
		{
			get { return (int)GetValue(IndexProperty); }
			set { SetValue(IndexProperty, value); }
		}

	}
}
